<template>
	<view>
		<custom-navigation-bar title="商家后台"></custom-navigation-bar>
		<view class="top">
			<view class="top_1">
				商户名：{{shopInfo.shop_name}}
			</view>
			<view class="top_1">
				账户余额：{{shopInfo.account}} <label class="btn-1">提现</label>
			</view> 
			<view style="width: 100%;height:20rpx;float: left;"></view>
		</view>
		
		<view class="menu_item" @click="goods">
			<view class="menu_item_1">
				商品管理<image src="../../../static/gengduo@3x(1).png" class="menu_item_img"></image>
			</view>
		</view>
		<view class="menu_item" @click="saoMa">
			<view class="menu_item_1">
				商品验码<image src="../../../static/gengduo@3x(1).png" class="menu_item_img"></image>
			</view>
		</view>
		<view class="menu_item" @click="orders">
			<view class="menu_item_1">
				订单管理<image src="../../../static/gengduo@3x(1).png" class="menu_item_img"></image>
			</view>
		</view>
		<view class="menu_item" @click="comment">
			<view class="menu_item_1">
				评论管理<image src="../../../static/gengduo@3x(1).png" class="menu_item_img"></image>
			</view>
		</view>
		<view class="menu_item" @click="balance">
			<view class="menu_item_1">
				资金明细<image src="../../../static/gengduo@3x(1).png" class="menu_item_img"></image>
			</view>
		</view>
		<view class="menu_item" >
			<view class="menu_item_1">
				提现记录<image src="../../../static/gengduo@3x(1).png" class="menu_item_img"></image>
			</view>
		</view>
		
		 
		<view class="menu_item">
			<view class="menu_item_2" @click="out()">
				 退出登录
			</view>
		</view>
	</view>
</template>

<script setup> 
	import CustomNavigationBar from '@/components/CustomNavigationBar.vue'
	import http from '../../../utils/http'; 
	function applicationManagement(){
		uni.navigateTo({
			url:"/pages/approve/approve"
		})
	}
	//商品列表
	function goods(){ 
		uni.navigateTo({ 
			url: "/pages/my/shop/goods"
		})
	}
	//订单列表
	function orders(){
		uni.navigateTo({
			url: "/pages/my/shop/order"
		})
	}
	//评论管理
	function comment(){
		uni.navigateTo({
			url: "/pages/my/shop/comment"
		})
	}
	function balance(){
		uni.navigateTo({
			url: "/pages/my/shop/balance"
		})
	}
	function out(){
		getApp().globalData.shopUserId='';
		wx.setStorage({
		  key: "shopUserId",
		  data: -1, 
		  success() {
			wx.switchTab({
			  url: "/pages/my/my",
			  success: function(res) {
			    // 跳转成功
			  },
			  fail: function(err) {
			    // 错误处理
			  }
			})
		  }
		}) 
		
	}
	
	import {
		onLoad,onShow,
		onPageScroll
	} from '@dcloudio/uni-app';
	const shopInfo=ref({});
	const shopId=ref();
	onLoad((query) => {
		 
	})
	onShow(() => {
		http.request({
		 	url: "/shop/goods/get/getShopInfo",
		 	method: "POST",
		 	data: {
		 		"userId":getApp().globalData.shopUserId
		 	}
		}).then((responseData) => { 
			 if(responseData.code==1){
				shopInfo.value=responseData.data;
			 }else if(responseData.code==-1){
				 getApp().globalData.shopUserId=''
				 wx.setStorage({
				   key: "shopUserId",
				   data: -1, 
				   success() {
					  console.log("11111111111111111111111111111111111111111") 
				 	  uni.navigateBack(); 
				   }
				 })  
				 
			 }
		}).catch((err) => { 
		 	uni.showToast({
		 		icon: 'error',
		 		title: '请求失败'
		 	})
		})
	})
	
	function saoMa(){
		
		wx.scanCode({
		  //scanType: ['QR_CODE'], //条形码
		  onlyFromCamera: true,
		  success (res) {
		    console.log(res)
			if (res.errMsg == "scanCode:ok") {
					// 扫描到的信息
				console.log(res.result);
				uni.navigateTo({
					url: "/pages/my/shop/yanMa"+res.result
				})
			} else {
				console.log("未识别到二维码，请重新尝试！")
			}
		  }
		})
		
		// uni.scanCode({
		// 	 scanType: ['QR_CODE'], //条形码
		// 	success: function(res) {
		// 			// console.log('条码类型：' + res.scanType);
		// 			// console.log('条码内容：' + res.result);
		// 			// 微信小程序
		// 		if (res.errMsg == "scanCode:ok") {
		// 				// 扫描到的信息
		// 			console.log(res.result);
		// 			uni.navigateTo({
		// 				url: "/pages/my/shop/yanMa"+res.result
		// 			})
		// 		} else {
		// 			console.log("未识别到二维码，请重新尝试！")
		// 		}
		// 	}
		// });
	}
</script>

<style>
	.menu_item_2{
		width: 84%;margin-left: 8% ;height: 80rpx;line-height: 80rpx;float:left;text-align: center;font-size: 30rpx;font-weight: bold;
	}
	.menu_item_img{
		width: 40rpx;height: 40rpx;float: right;margin-top: 20rpx;
	}
	.menu_item_1{
		width: 84%;margin-left: 8% ;float: left;height: 80rpx;line-height: 80rpx;float:left;font-size:28rpx;font-weight: bold;
	}
	.menu_item{
		width: 100%;float: left;height: 80rpx;line-height: 80rpx;margin-top: 10rpx;background:white;
	}
	Page{
		background-color: #F2F2F2;
		font-size: 30rpx;
	}
	.btn-1{
		width: auto;border: #969696 3rpx solid;color: #969696;border-radius:10rpx;padding-left: 8rpx;padding-right: 10rpx;font-size: 28rpx;margin-left: 10rpx;
	}
	.top{
		width: 100%;height:auto;margin-top: 150rpx;background: #2AE8DC;float: left;font-size: 30rpx;
	}
	.top_1{
		width: 80%;height: 50rpx;line-height: 50rpx;float: left;margin-left: 10%;color: white;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;
	}
</style>